gametheory
Class Game

java.lang.Object
  extended by gametheory.Game
All Implemented Interfaces:
java.io.Serializable

public class Game
extends java.lang.Object
implements java.io.Serializable

Contains all the information for a discrete game of complete information: actions, payoffs, importance games, and equilibria.

See Also:
Serialized Form

Constructor Summary
Game(int numPlayers, int numActions)
          Creates a new instance of Game
 
Method Summary
 void calculateUtilities()
          Computes utilities for use in importance games and Monte Carlo.
 Game deepCopy()
          Creates a deep copy of the current game.
 void findEfficientEquilibrium()
          Compute the efficient equilibrium and store the result through setEfficientIndex.
 int findIndexAction(Jama.Matrix findMe)
          Calculates the index of an action in the actionList.
 void generateEmptyPayoffList()
          Creates a new, empty payoff list.
 java.util.ArrayList<Jama.Matrix> getActionList()
          Get list of actions.
 boolean[] getDominatedEnumeration()
          Get enumeration of dominated strategies.
 int getEfficientIndex()
          Get index of the efficient equilibrium.
 java.util.ArrayList<double[]> getEquilibria()
          Obtain the set of equilibria associated with this game.
 double getExpectedValueEquilibrium(int equilibriumNumber)
          Computes the expected value of an equilibrium; used for finding the efficient equilibrium in the set.
 double getExpectedValueEquilibrium(int equilibriumNumber, int playerIndex)
          Calculate the expected value of a particular equilibrium for a specific player.
 double getHQRatio(double[] x, java.util.ArrayList<Jama.Matrix> expectedProfitsList)
          Computes the importance weight for the current game.
 java.util.ArrayList<Game> getImportanceGamesList()
          Get the importance games list.
 double getLambda(int equilibriumIndex, double[] x)
          Computes the probability of an equilibrium being selected in a play of the game.
 int getNumActions()
          Get the number of actions.
 int getNumMixedEqu()
          Get the number of mixed strategy equilibria.
 int getNumPlayers()
          Get number of players.
 int getNumPureEqu()
          Get the number of pure strategy equilibria.
 Jama.Matrix getOutcome()
          Get the simulated outcome.
 java.util.ArrayList<Jama.Matrix> getPayoffList()
          Get deterministic payoff list.
 double getProbabilityAction(int actionIndex, double[] x)
          Compute a single moment for this game.
 boolean[] getPureEnumeration()
          Get enumeration of pure strategies.
 Jama.Matrix getSimulatedOutcome()
          Simulate an outcome from the game.
 java.lang.String getUtilitiesFlatString()
          Returns string form of utilityList.
 java.util.ArrayList getUtilityList()
          Get the utility list.
 void outputActions()
          Output list of all actions to the console.
 void outputGame(java.lang.String filename)
          Print game to filename.
 void setDominatedEnumeration(boolean[] dominatedEnumeration)
          Set enumeration of dominated strategies.
 void setEfficientIndex(int efficientIndex)
          Set index of the efficient equilibrium.
 void setEquilibria(java.util.ArrayList<double[]> equilibria)
          Set equilibria to this game and enumerate their types (dominated, efficient, mixed/pure)
 void setImportanceGamesList(java.util.ArrayList<Game> aImportanceGamesList)
          Set importance games list.
 void setNumMixedEqu(int numMixedEqu)
          Set the number of mixed strategy equilibria.
 void setNumPureEqu(int numPureEqu)
          Set the number of pure strategy equilibria.
 void setOutcome(Jama.Matrix outcome)
          Set simulated outcome.
 void setPayoff(Jama.Matrix action, int playerIndex, double payoff, boolean report)
          Sets payoff for specific player and action.
 void setPayoffList(java.util.ArrayList<Jama.Matrix> payoffList)
          Set the payoff List.
 void setPureEnumeration(boolean[] pureEnumeration)
          Set enumeration of pure strategies.
 void setUtilityList(java.util.ArrayList<Jama.Matrix> utilityList)
          Set the utility list.
 java.lang.String stringVector(Jama.Matrix x)
          Convert Matrix to string.
 java.lang.String toString()
          Returns a string representation of the game.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Game

public Game(int numPlayers,
            int numActions)
Creates a new instance of Game

Parameters:
numPlayers - Number of players.
numActions - Number of actions.
Method Detail

deepCopy

public Game deepCopy()
Creates a deep copy of the current game.

Returns:
A deep copy clone of the current game.

getExpectedValueEquilibrium

public double getExpectedValueEquilibrium(int equilibriumNumber)
Computes the expected value of an equilibrium; used for finding the efficient equilibrium in the set.

Parameters:
equilibriumNumber - Index of the equilibrium the expected value is to be calculated for.
Returns:
Expected value of the equilibrium.

getExpectedValueEquilibrium

public double getExpectedValueEquilibrium(int equilibriumNumber,
                                          int playerIndex)
Calculate the expected value of a particular equilibrium for a specific player.

Parameters:
equilibriumNumber - Index of equilibrium to evaluate.
playerIndex - Index of player to evaluate.
Returns:
Expected value of that equilibrium for a given player.

findEfficientEquilibrium

public void findEfficientEquilibrium()
Compute the efficient equilibrium and store the result through setEfficientIndex.


getSimulatedOutcome

public Jama.Matrix getSimulatedOutcome()
Simulate an outcome from the game.

Returns:
Matrix containing the equilibrium actions of all players.

getProbabilityAction

public double getProbabilityAction(int actionIndex,
                                   double[] x)
Compute a single moment for this game. Equivalently, this method returns the probability of observing a given outcome. The method computes this probability by summing over importance games and computing the probability of observing the outcome under each of the importance game's equilibria.

Parameters:
actionIndex - Index of action to compute the moment for.
x - Vector of unknown parameters.
Returns:
Probability of seeing that action played in the data.

getLambda

public double getLambda(int equilibriumIndex,
                        double[] x)
Computes the probability of an equilibrium being selected in a play of the game.

Parameters:
equilibriumIndex - Index of equilibrium to be evaluated.
x - Vector of unknown parameters.
Returns:
Probability that equilibrium will be selected in a play of the game.

getHQRatio

public double getHQRatio(double[] x,
                         java.util.ArrayList<Jama.Matrix> expectedProfitsList)
Computes the importance weight for the current game.

Parameters:
x - Vector of unknown parameters.
expectedProfitsList - ArrayList of deterministic expected profits.
Returns:
Importance weight for this game.

calculateUtilities

public void calculateUtilities()
Computes utilities for use in importance games and Monte Carlo.


generateEmptyPayoffList

public void generateEmptyPayoffList()
Creates a new, empty payoff list.


findIndexAction

public int findIndexAction(Jama.Matrix findMe)
Calculates the index of an action in the actionList.

Parameters:
findMe - Jama.Matrix representation of the action to find.
Returns:
The index of the action in actionList.

outputActions

public void outputActions()
Output list of all actions to the console.


setPayoff

public void setPayoff(Jama.Matrix action,
                      int playerIndex,
                      double payoff,
                      boolean report)
Sets payoff for specific player and action.

Parameters:
action - Action to assign payoff to.
playerIndex - Index of player.
payoff - Value to assign.
report - Switch to print debugging information.

getUtilitiesFlatString

public java.lang.String getUtilitiesFlatString()
Returns string form of utilityList.

Returns:
String form of utilityList.

toString

public java.lang.String toString()
Returns a string representation of the game.

Overrides:
toString in class java.lang.Object
Returns:
String representation of the game.

stringVector

public java.lang.String stringVector(Jama.Matrix x)
Convert Matrix to string.

Parameters:
x - Matrix to convert.
Returns:
String form of Matrix.

outputGame

public void outputGame(java.lang.String filename)
Print game to filename.

Parameters:
filename - Name of file to output game to.

getActionList

public java.util.ArrayList<Jama.Matrix> getActionList()
Get list of actions.

Returns:
List of actions.

getPayoffList

public java.util.ArrayList<Jama.Matrix> getPayoffList()
Get deterministic payoff list.

Returns:
Deterministic payoff list.

getNumPlayers

public int getNumPlayers()
Get number of players.

Returns:
Number of players.

getNumActions

public int getNumActions()
Get the number of actions.

Returns:
Number of actions.

getEquilibria

public java.util.ArrayList<double[]> getEquilibria()
Obtain the set of equilibria associated with this game.

Returns:
The set of equilibria associated with this game.

setEquilibria

public void setEquilibria(java.util.ArrayList<double[]> equilibria)
Set equilibria to this game and enumerate their types (dominated, efficient, mixed/pure)

Parameters:
equilibria - Array containing equilibria to be enumerated.

getOutcome

public Jama.Matrix getOutcome()
Get the simulated outcome.

Returns:
The simulated outcome.

setOutcome

public void setOutcome(Jama.Matrix outcome)
Set simulated outcome.

Parameters:
outcome - The simulated outcome.

getImportanceGamesList

public java.util.ArrayList<Game> getImportanceGamesList()
Get the importance games list.

Returns:
The list of importance games.

setImportanceGamesList

public void setImportanceGamesList(java.util.ArrayList<Game> aImportanceGamesList)
Set importance games list.

Parameters:
aImportanceGamesList - The list of importance games.

getNumMixedEqu

public int getNumMixedEqu()
Get the number of mixed strategy equilibria.

Returns:
The number of mixed strategy equilibria.

setNumMixedEqu

public void setNumMixedEqu(int numMixedEqu)
Set the number of mixed strategy equilibria.

Parameters:
numMixedEqu - Number of mixed strategy equilibria.

getNumPureEqu

public int getNumPureEqu()
Get the number of pure strategy equilibria.

Returns:
The number of pure strategy equilibria.

setNumPureEqu

public void setNumPureEqu(int numPureEqu)
Set the number of pure strategy equilibria.

Parameters:
numPureEqu - Number of pure strategy equilibria.

setPayoffList

public void setPayoffList(java.util.ArrayList<Jama.Matrix> payoffList)
Set the payoff List.

Parameters:
payoffList - ArrayList of payoffs.

getPureEnumeration

public boolean[] getPureEnumeration()
Get enumeration of pure strategies.

Returns:
Enumeration of pure strategies.

setPureEnumeration

public void setPureEnumeration(boolean[] pureEnumeration)
Set enumeration of pure strategies.

Parameters:
pureEnumeration - Enumeration of pure strategies.

getEfficientIndex

public int getEfficientIndex()
Get index of the efficient equilibrium.

Returns:
Index of the efficient equilibrium.

setEfficientIndex

public void setEfficientIndex(int efficientIndex)
Set index of the efficient equilibrium.

Parameters:
efficientIndex - Index of the efficient equilibrium.

getUtilityList

public java.util.ArrayList getUtilityList()
Get the utility list.

Returns:
The list of utilities.

setUtilityList

public void setUtilityList(java.util.ArrayList<Jama.Matrix> utilityList)
Set the utility list.

Parameters:
utilityList - The list of utilities.

getDominatedEnumeration

public boolean[] getDominatedEnumeration()
Get enumeration of dominated strategies.

Returns:
The enumeration of dominated strategies.

setDominatedEnumeration

public void setDominatedEnumeration(boolean[] dominatedEnumeration)
Set enumeration of dominated strategies.

Parameters:
dominatedEnumeration - Enumeration of dominated strategies.